<?php
namespace app\index\controller\user;
use app\index\model\Users;
use app\index\model\UsersInfo;
class BaseUser extends \think\Controller{
    public $userdata = false;
    public function __construct(){
        parent::__construct();
        //判断是否登录
        $session_id = \think\Session::get('uid');
        if($session_id < 1){
            return $this->error('当前操作需要管理员登录！请先登录！','index/Login/index');
        }
        //查询数据库中是否有用户信息
        $users = new Users();
        $this->userdata = $users->where('id',$session_id)->find();
        if(!$this->userdata){
            return $this->error('非法操作，请重新登录！','index/Login/index');
        }
        $users_id = $this->userdata['id'];

        $users_info = new UsersInfo();
        $result = $users_info->where('users_id',$this->userdata['id'])->find();          
        //向模板赋值
        $this->assign('userdata',$result);              
    }


}